const { program } = require("commander");
const createProjectHandle = require("./action.js");

function optionsHelp() {
  //打印版本
  const version = require("../../package.json").version;
  program.version(version, "-v --version");
  //options增强

  program.option("-desc --description", " a custom cli program is running");

  program.option("-d --dest <dest>", "a destination folder ,for example : -d src/components");

  //增加具体的一些功能操作
  createProjectHandle();

  //补充help命令
  program.on("--help", () => {
    console.log("");
    console.log("others command:");
    console.log("  xxx");
    console.log("  yyy");
  });

  //让commander解析process.argv参数
  program.parse(process.argv);

  //获取额外传递的参数
  // console.log(program.opts().dest);
}

module.exports = optionsHelp;
